Skip to content

Fixed flaky test testDateHandling in TimestampsParquetReaderTest.java with JSONAssert#1

Open
CaseyPan wants to merge 4 commits into
masterfrom
fix-flaky
Open

Fixed flaky test testDateHandling in TimestampsParquetReaderTest.java with JSONAssert#1
CaseyPan wants to merge 4 commits into
masterfrom
fix-flaky

Conversation

@CaseyPan

@CaseyPan CaseyPan commented Sep 27, 2023

Copy link
Copy Markdown
Owner

Description

Fixed flaky test testDateHandling in TimestampsParquetReaderTest.java with JSONAssert

Location: extensions-core/parquet-extensions
Filename: TimestampsParquetReaderTest.java
Test: testDateHandling

  1. Test Overview:
    In the TimestampsParquetReaderTest.testDateHandling test, we assess how timestamps are handled in Parquet files, focusing on date values stored as strings and date objects. The test checks the consistency of timestamp conversion and verifies that the JSON representations of these timestamps match the expected values.

  2. Reason of flakiness:
    However, a potential problem arises because the data reading methods used createReader() does not always retrieve data in a consistent order, possibly introducing randomness. This can lead to different JSON representations of the same data during test runs.

  3. Changes:

  • Imported JSONAssert and JSONException packages, and changed from using standard assertion method Assert to using JSONAssert when comparing two results sampledAsString and sampledAsDate with expectedJson.

  • Add org.json and org.skyscreamer dependencies to pom.xml file in /parquet-extensions.

    To address this issue, the PR proposes changing the comparison approach from a standard assertion method Assert to using JSONAssert.
    JSONAssert method allows for a comparison of data equality without considering the order in which the data is retrieved. This change ensures more reliable and consistent test results across different runs, regardless of variations in data retrieval order.

Release note

Fixed: TimestampsParquetReaderTest.testDateHandling test no longer fail when running with the NonDex tool.


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@sansim26 sansim26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one suggestion is to provide links to documentation for data reading methods used may not always retrieve data in a consistent order

@Suraj-Vashista-BK Suraj-Vashista-BK left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!. Please check for code style. There can be checkstyle errors.

@219sansim 219sansim left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments

@zzjas zzjas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's your call to spend more time addressing the comments or not, but we approve you to proceed to open a real PR. Once you open a real PR, please mark this tentative PR as Opened in your tentative_pr.csv file and also raise a PR to IDoFT marking this as Opened. Thanks!

try {
JSONAssert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampledAsString.get(0).getRawValues()), false);
JSONAssert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampledAsDate.get(0).getRawValues()), false);
} catch (JSONException jse) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the JSONException type necessary here? Developers might be reluctant to add a new dependency for printing an error message in a test.

@219sansim 219sansim left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can remove dependencies that you included in the code.

@zzjas

zzjas commented Oct 17, 2023

Copy link
Copy Markdown

Have you opened a real PR for this? If so, please mark this as "Opened" in your tentative_pr.csv file and also raise a PR to IDoFT marking this as Opened. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants